package com.cryptoneedle.garden.service.crud.garden.source;

import com.cryptoneedle.garden.entity.source.constraint.*;
import com.cryptoneedle.garden.entity.source.enhance.SourceDimension;
import com.cryptoneedle.garden.entity.source.metadata.SourceCatalog;
import com.cryptoneedle.garden.entity.source.metadata.SourceColumn;
import com.cryptoneedle.garden.entity.source.metadata.SourceDatabase;
import com.cryptoneedle.garden.entity.source.metadata.SourceTable;
import com.cryptoneedle.garden.repository.source.constraint.*;
import com.cryptoneedle.garden.repository.source.enhance.SourceDimensionRepository;
import com.cryptoneedle.garden.repository.source.metadata.*;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>description:  </p>
 *
 * @author CryptoNeedle
 * @date 2025-10-23
 */
@Slf4j
@Service
@Transactional
public class DeleteSourceService {

    @Autowired
    private FoundSourceService select;
    @Autowired
    private AddSourceService add;
    @Autowired
    private PatchSourceService patch;
    @Autowired
    private SaveSourceService save;
    @Autowired
    private DeleteSourceService delete;

    @Resource
    private SourceServerRepository sourceServerRepository;
    @Resource
    private SourceCatalogRepository sourceCatalogRepository;
    @Resource
    private SourceDatabaseRepository sourceDatabaseRepository;
    @Resource
    private SourceTableRepository sourceTableRepository;
    @Resource
    private SourceColumnRepository sourceColumnRepository;

    @Resource
    private SourceConstraintCheckRepository sourceConstraintCheckRepository;
    @Resource
    private SourceConstraintForeignRepository sourceConstraintForeignRepository;
    @Resource
    private SourceConstraintPrimaryRepository sourceConstraintPrimaryRepository;
    @Resource
    private SourceConstraintUniqueRepository sourceConstraintUniqueRepository;
    @Resource
    private SourceIndexUniqueRepository sourceIndexUniqueRepository;

    @Resource
    private SourceDimensionRepository sourceDimensionRepository;

    /**
     * SourceServerRepository
     */
    public void serversClean() {
        sourceServerRepository.serversClean();
    }

    /**
     * SourceCatalogRepository
     */
    public void delete(SourceCatalog entity) {
        sourceCatalogRepository.delete(entity);
    }

    public void catalogs(List<SourceCatalog> list) {
        sourceCatalogRepository.deleteAll(list);
    }

    /**
     * SourceDatabaseRepository
     */
    public void delete(SourceDatabase entity) {
        sourceDatabaseRepository.delete(entity);
    }

    public void databases(List<SourceDatabase> list) {
        sourceDatabaseRepository.deleteAll(list);
    }

    /**
     * SourceTableRepository
     */
    public void delete(SourceTable entity) {
        sourceTableRepository.delete(entity);
    }

    public void tables(List<SourceTable> list) {
        sourceTableRepository.deleteAll(list);
    }

    /**
     * SourceColumnRepository
     */
    public void delete(SourceColumn entity) {
        sourceColumnRepository.delete(entity);
    }

    public void columns(List<SourceColumn> list) {
        sourceColumnRepository.deleteAll(list);
    }

    /**
     * SourceConstraintCheckRepository
     */
    public void delete(SourceConstraintCheck entity) {
        sourceConstraintCheckRepository.delete(entity);
    }

    public void constraintChecks(List<SourceConstraintCheck> list) {
        sourceConstraintCheckRepository.deleteAll(list);
    }

    /**
     * SourceConstraintForeignRepository
     */
    public void delete(SourceConstraintForeign entity) {
        sourceConstraintForeignRepository.delete(entity);
    }

    public void constraintForeigns(List<SourceConstraintForeign> list) {
        sourceConstraintForeignRepository.deleteAll(list);
    }

    /**
     * SourceConstraintPrimaryRepository
     */
    public void delete(SourceConstraintPrimary entity) {
        sourceConstraintPrimaryRepository.delete(entity);
    }

    public void constraintPrimarys(List<SourceConstraintPrimary> list) {
        sourceConstraintPrimaryRepository.deleteAll(list);
    }

    /**
     * SourceConstraintUniqueRepository
     */
    public void delete(SourceConstraintUnique entity) {
        sourceConstraintUniqueRepository.delete(entity);
    }

    public void constraintUniques(List<SourceConstraintUnique> list) {
        sourceConstraintUniqueRepository.deleteAll(list);
    }

    /**
     * SourceIndexUniqueRepository
     */
    public void delete(SourceIndexUnique entity) {
        sourceIndexUniqueRepository.delete(entity);
    }

    public void indexUniques(List<SourceIndexUnique> list) {
        sourceIndexUniqueRepository.deleteAll(list);
    }

    /**
     * SourceDimensionRepository
     */
    public void delete(SourceDimension entity) {
        sourceDimensionRepository.delete(entity);
    }

    public void dimensions(List<SourceDimension> list) {
        sourceDimensionRepository.deleteAll(list);
    }

}